home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / stnvjw20.zip / SETENV.SYN < prev    next >
Text File  |  1992-10-25  |  12KB  |  437 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. setenv command line syntax:
  7.  
  8. <prog>    %rce    <variable>    <options>
  9.  
  10. setenv        <variable>    <no value>
  11.                 <value>
  12.                 %chgup
  13.                 %chglo
  14.                 %rep<del><text1><del><text2><del>
  15.                 %prompt    <prompt options> <message>
  16.                 %<operator> [<string>|<var>] [<string>|<var>]
  17.  
  18. <prog>
  19.     setenv program to handle environment variables
  20.  
  21. <variable> or <var>
  22.     the name, the environment variable name
  23.     any valid environment variable you wish to define or re-define
  24.  
  25. <options>
  26.     functions to preform for an environment variable
  27.  
  28. <no value>
  29.     no data entered, so as to erase the variable
  30.  
  31. <value>
  32.     a string of printable characters
  33.     the data portion for the environment variable
  34.     any number of <keys> can be imbedded in the character string
  35.  
  36. <del>
  37.     any one character, to delimit or to quote <text>
  38.     the delimiter must be consistent for the option used
  39.  
  40. <text>
  41.     a string of printable characters
  42.     any variable length text {maximum length 100}
  43.  
  44. <text1>
  45.     a string of printable characters
  46.     any variable length text {maximum length 100}
  47.  
  48. <text2>
  49.     a string of printable characters
  50.     any variable length text {maximum length 100}
  51.  
  52. <string>
  53.     a string of printable characters, enclosed by single or double quotes
  54.     any variable length text {maximum length 100}
  55.  
  56. <number> or <n>
  57.     a string of digits that can be considered a number
  58.     there usually is maximum numeric size for the number's function
  59.  
  60.  
  61.  
  62.  
  63. setenv command line syntax continued:
  64.  
  65. <message>
  66.     a string of printable characters
  67.     is displayed and the response is set into the <variable>
  68.     can have embedded %/<number>/ to create characters
  69.  
  70. <operator>
  71.     any one of the follow logical operators: eq, lt, le, gt, ge
  72.  
  73. <prompt options>
  74.     subfunctions to perform for %prompt
  75.  
  76. <keys>
  77.     special names that are imbedded in <value>
  78.     usually begining  with a % {percent sign}
  79.     a key will denote a special function like %time
  80.  
  81. <special keys>
  82.     special names that are imbedded in <value>, but have arguments
  83.     usually begining  with a % {percent sign}
  84.     a key will denote a special function like %len
  85.  
  86. %rce
  87.     is used when command.com has been called a second time
  88.     to set the environment variable in the root environment space
  89.  
  90. <options>
  91.  
  92.     <no value>
  93.         no data entered
  94.         environment variable by it's self to erase it
  95.  
  96.     <value>
  97.         any length data for the environment variable
  98.         any number of <keys> can be imbedded in the data
  99.  
  100.     %chgup
  101.         change the existing environment variable's data to uppercase
  102.  
  103.     %chglo
  104.         change the existing environment variable's data to lowercase
  105.  
  106.     %rep<del><text1><del><text2><del>
  107.         replace any occurence  of <text1> with any occurence of 
  108.         <text2> in the  existing environment variable
  109.  
  110.     %prompt    <prompt options> <message>
  111.         prompt the display with <messsage> for <variable>'s data
  112.  
  113.  
  114.  
  115.  
  116. setenv command line syntax continued:
  117.  
  118. <options>
  119.  
  120.     %eq [<string>|<variable>] [<string>|<variable>]
  121.         tests if two values are equal
  122.         the value can be a string or variable's content
  123.         a string is a quoted with single or double quotes.
  124.         returns T for true, F for false, or E for error
  125.  
  126.     %lt [<string>|<variable>] [<string>|<variable>]
  127.         tests if value one is less than value two
  128.         the value can be a string or variable's content
  129.         returns T for true, F for false, or E for error
  130.  
  131.     %le [<string>|<variable>] [<string>|<variable>]
  132.         tests if value one is less than or equal value two
  133.         the value can be a string or variable's content
  134.         returns T for true, F for false, or E for error
  135.  
  136.     %gt [<string>|<variable>] [<string>|<variable>]
  137.         tests if value one is greater than value two
  138.         the value can be a string or variable's content
  139.         returns T for true, F for false, or E for error
  140.  
  141.     %ge [<string>|<variable>] [<string>|<variable>]
  142.         tests if value one is greater than or equal value two
  143.         the value can be a string or variable's content
  144.         returns T for true, F for false, or E for error
  145.  
  146. <keys>
  147.     special names that are imbedded in <value>
  148.     usually begining  with a % {percent sign}
  149.     a key will denote a special function like %time
  150.  
  151.     %cwd
  152.         the current working directory, will be "/" if at the top
  153.     %cfd
  154.         the current full directory specification, "/" if at the top
  155.     %date1 or %date
  156.         the current date as dd:mm:yy, day first
  157.     %date2
  158.         the current date as mm:dd:yy, month first
  159.     %date3
  160.         the current date as yy:dd:mm, year first
  161.     %dosv
  162.         MS-DOS major version
  163.     %dosm
  164.         MS-DOS minor version
  165.     %drive
  166.         current working disk drive letter
  167.     %time
  168.         the current time as hh:mm:ss
  169.     %+n
  170.         plus "n"'s disk drive letter from current drive
  171.     %-n
  172.         minus "n"'s disk drive letter from current drive
  173.  
  174.  
  175.  
  176.  
  177.  
  178. setenv command line syntax continued:
  179.  
  180. <special keys>
  181.     %chr<del><number><del>
  182.         returns that ascii code as a character, range 1 - 255
  183.  
  184.     %elem<del><number><del><character><del><variable><del>
  185.         extracts element <number> from the string of elements
  186.         separated by <character>
  187.         '0' the first element if the element precedes the first
  188.         <character>
  189.  
  190.     %mid<del><variable><del><number1><del><number2><del>
  191.         returns a string of length <number1> from
  192.         <variable> starting from <number2>
  193.  
  194.     %loc<del><number><del><variable><del><text><del>
  195.         searches for the first occurrence of the <text>
  196.         in <variable> starting at location <number> and
  197.         returns the offset of <text>
  198.         returns '0' if <text> not found
  199.  
  200.     %len<del><variable><del>
  201.         returns the number of characters in <variable>,
  202.         but only the data portion
  203.  
  204.     %sum<del><variable><del><number><del>
  205.         returns the sum of <number> and <variable>
  206.         <number> can be negative
  207.  
  208. <del>
  209.     any one character, to delimit or to quote <text>
  210.     the delimiter must be consistent for the option used
  211.  
  212. <character>
  213.     any one character
  214.  
  215. <variable>
  216.     the name, the environment variable name
  217.     any valid environment variable you wish to define or re-define
  218.  
  219. <text>
  220.     a string of printable characters
  221.     any variable length text {maximum length 20}
  222.  
  223. <number>
  224.     any number from 0 to 255
  225.  
  226. <number1>
  227.     any number from 0 to 255
  228.  
  229. <number1>
  230.     any number from 0 to 255
  231.  
  232.  
  233.  
  234.  
  235.  
  236. setenv command line syntax continued:
  237.  
  238. <prompt options>
  239.  
  240.     %def<def><text><del>
  241.         if no data is entered at the prompt then use <text>
  242.         no data entered is a soul carriage return
  243.  
  244.     %noecho
  245.         when data is entered do not display it
  246.         necessary for passwords, 
  247.         remember to ersae the variable after use
  248.         
  249.     %timo=hh:mm:ss
  250.         exit prompt, if no data is entered in the time hh:mm:ss 
  251.         if no %def accompanies this option then %def// is assumed
  252.         ss for seconds, mm:ss for minutes, hh:mm:ss for hours
  253.  
  254.     %upper
  255.         convert prompted / entered data to uppercase
  256.  
  257.     %lower
  258.         convert prompted / entered data to lowercase
  259.  
  260.     %trim
  261.         trim leading and trailing spaces from entered line
  262.  
  263.  
  264.  
  265.  
  266.  
  267. setenv command examples:
  268.  
  269. To create a variable
  270.     setenv name John Wolchak
  271.  
  272. To erase a variable
  273.     setenv name
  274.  
  275. To prompt a question
  276.     setenv node %prompt Node name to connect to 
  277.  
  278. To prompt passwords
  279.     setenv pass %prompt %noecho Your password 
  280.  
  281. When you want to pass on a string with spaces in it to a batch file
  282.     batfile this_is_a_test
  283.     setenv name %%rep/_/ /
  284.  
  285. When you want to minimize parsing data, use uppercase
  286.     set name=John
  287.     setenv name %%chgup
  288.     or
  289.     setenv name %%prompt %%upper Your first name 
  290.  
  291. To given batch files startup options
  292.     prompt:
  293.     setenv ans %%prompt %%upper %%def/N/ Connect to the Network (Y/N) 
  294.     setenv ans %%rep/ES//
  295.     setenv ans %%rep/ //
  296.     setenv ans %%rep/O//
  297.     if "%ans%" == "Y" goto network
  298.     if not "%ans%" == "N" goto prompt
  299.  
  300. To give batch files startup options, that can be unattendable as well
  301.     prompt:
  302.     setenv ans %%prompt %%upper %%def/N/ %%timo=20 Network Connect (Y/N) 
  303.     if "%ans%" == "Y" goto network
  304.     if not "%ans%" == "N" goto prompt
  305.  
  306. For timing test
  307.     setenv start Starting time %%time
  308.     myporg
  309.     setenv end Ending time %%time
  310.  
  311. For batch proceedures that move around and return
  312.     setenv retdrv %%drive:
  313.     setenv retdir %%cwd
  314.     ...
  315.     ...
  316.     %retdrv%
  317.     cd %retdir%
  318.  
  319.  
  320.  
  321.  
  322.  
  323. setenv command examples continued:
  324.  
  325. To save a directory for later use:
  326.     setenv drvdir %%drive:%%cwd
  327.     cd d:\tmp
  328.     .
  329.     .
  330.     .
  331.     cd %drvdir%
  332.  
  333. To check for files:
  334.     setenv drvdir %%drive:%%cfd
  335.     setenv file THISFILE.TXT
  336.     cd d:\tmp
  337.     if exist %drvdir%%file% then echo got it
  338.     
  339. To check passwords
  340.     :loop
  341.     setenv pass %%prompt %%trim %%noecho Password 
  342. answer:
  343.     Password ttt
  344.     setenv len %%len/pass/
  345.     setenv tst %%lt len '6'
  346.     if "%tst%" == "F" goto cont
  347.     echo password length is %len% should be 6 or more
  348.     goto loop
  349.     :cont
  350.  
  351. To get and group and separate arguments
  352.     setenv full %%prompt %%trim Full Name 
  353. answer:
  354.     Full Name John Wolchak
  355.     setenv full %%rep/  / /
  356.     setenv full %%rep/  / /
  357.     setenv first %%elem/0/ /full/
  358.     setenv last %%%elem/1/ /full/
  359. or
  360.     setenv first %%prompt %%trim First Name 
  361. answer:
  362.     First Name John
  363.     setenv last %%prompt %%trim Last Name 
  364. answer:
  365.     Last Name Wolchak
  366.     setenv full %first% %last%
  367.  
  368.  
  369. To check input for data control
  370.     :loop
  371.     setenv ans %%prompt %%trim Selection Number (1-3) 
  372. answer:
  373.     Selection Number (1-3) 4
  374.     setenv log %%gt ans '3'
  375.     if "%log%" == "Y" goto loop
  376.     setenv log %%lt ans '1'
  377.     if "%log%" == "Y" goto loop
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384. setenv command examples continued:
  385.  
  386. For programs that spawn by calling command.com
  387.     setenv %rce name John
  388. which is the same as
  389.     c:\command /c setenv %rce name John
  390.  
  391.  
  392. To tell a program the start time, but you want it to start now.  The
  393. user normally would enter hh:mm:ss, but for the current time enter %time
  394.     setenv time %prompt Start time 
  395.     Start time
  396. answer:
  397.     Start time %time
  398.  
  399.  
  400.  
  401. setenv command special notes:
  402.  
  403.     In batch (BAT files) use %% to represent a single % for use 
  404. to SETENV.   ie. setenv drv_dir %%drive:%%cwd
  405. Which on the display screen would be:   ie. setenv drv_dir %drive:%cwd 
  406.  
  407.      In the preceding section scripts that would be in batch have 
  408. had %% in them.  In batch you can use %<environ_var>% to reflect the 
  409. value of a previous environment variable.  Make sure you have enough 
  410. environment space to store the amount of data you would need.  DOS 2.0 
  411. throught 3.20 have by default 160 bytes, and need manual extension.
  412. DOS 3.30 through 5.0 can be extended in the Config.Sys file.
  413.  
  414.     SETENV can not expand the environment space.  The DOS SET 
  415. command can do that, by creating temporary variables with long values 
  416. and then removing them before any resident program is run.  Resident 
  417. programs are PRINT, MODE.  Once a resident program is run then the 
  418. environment space can not be expanded, because it precedes the resident
  419. code in memory.  Documentation is available for versions of DOS 2 thru 
  420. 3.20 that modify DOS to have a larger environment area beyond the normal 
  421. 160 bytes, as default values in Command.Com.  For DOS 3.30 and above 
  422. use the shell /E:xxxx option.  
  423.  
  424.     %prompt, %chgup, %chglo, and %rep/// are replacments for a <value>
  425. field, not inaddition to.  The %prompt sub options are not suppose to 
  426. be order dependent, but the %prompt must precede the subfunctions.
  427.  
  428.     When you use %prompt and you do not use a %timo then the prompt 
  429. will remain until a carriage return is entered.  Having no %def and a 
  430. %timo will assume %def// for the %prompt.  The time out is for the first 
  431. character you enter, after the first character is entered you have 
  432. forever to enter the rest of the text.
  433.  
  434.     There is some question where SETENV will run under MS-DOS V1.x.  
  435. I don't know because I have not seen either, as of yet.
  436.  
  437.